package com.eks.linux.controller;

import com.eks.linux.service.CommandService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotBlank;
import java.util.List;

/**
 * CommandController
 *
 * @author: chenfenghai
 * @version: 1.0
 * @date: 2021-02-04 15:47
 */
@Validated
@RestController
public class CommandController {

    @Autowired
    CommandService commandService;

    @PostMapping("/command")
    public List<String> command(@NotBlank(message = "cmd不能为空") @RequestParam(name = "cmd") String cmd) {
        return commandService.execute(cmd);
    }
}
